package cc.mxtt.mvc.model;

import java.util.List;

import com.jfinal.plugin.activerecord.Model;

@SuppressWarnings("serial")
public class RolePower extends Model<RolePower>{
	
	public static final RolePower dao = new RolePower();
	
	public boolean getRole(long userID , int power){
		
		UserRole user = UserRole.dao.findFirst("select * from sys_user_role where user_id =?" , userID);
		
		
		boolean is = false;
		List<RolePower> list =  dao.find("select * from sys_role_power where role_id =?", user.getLong("role_id"));
		for (RolePower rolePower : list) {
			long id = rolePower.getLong("power_id");
			if(power == id){
				is = true ;
				return is;
			}
		}
		
		return is;
	}

}
